<template>
  <div>
    {{form}}
    <p>姓名：<input type="text" v-model="form.name"></p>
    <p>用户名：<input type="text" v-model="form.username"></p>
    <p>密码：<input type="text" v-model="form.password"></p>
    <p>年级:
      <select name="" id="" v-model="form.gradeid">
        <option :value="i.id" v-for="i in gradelist">{{i.name}}</option>
      </select>
    </p>
    <p>
      <button @click="add">注册</button>
    </p>
  </div>
</template>

<script>
export default {
  name: "day105_register",
  data() {
    return {
      form:{},
      gradelist:[]
    }
  },
  methods: {
    get_grade(){
      this.$axios.get('teacher/grade/').then(res=>{
        this.gradelist =res.data.list
      })
    },
    add(){
      this.$axios.post('teacher/grade/',this.form).then(res=>{
        if(res.data.code == 200){
          localStorage.setItem('userid',res.data.userid)
          localStorage.setItem('name',res.data.name)
          this.$router.push({'path':'day105_stushow'})
        }
      })
    }
  },
  mounted() {
    this.get_grade()
    // localStorage.setItem('userid','')
    // localStorage.setItem('name','')
  }

}
</script>

<style scoped>

</style>
